<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	UserBean user = (UserBean) request.getSession().getAttribute(
			"userBean");

	String _db = user.getDbType();
	Map<String, List<Map<String, String>>> dicMap = user.getDicMap();
	List<Map<String, String>> list = null;
	String temp = "";

	String tbe_marital_status = "";//婚姻状态
	list = null;
	list = dicMap.get("27");
	if (null != list && list.size() > 0) {
		for (Map<String, String> map : list) {
			tbe_marital_status += "<option value=\""
					+ map.get("tmgd_id") + "\">" + map.get("tmgd_name")
					+ "</option>";
		}
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<link type="text/css" rel="stylesheet"
			href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet"
			href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet"
			href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript"
			src="ligerUI/js/plugins/ligerDateEditor.js"></script>

		<script type="text/javascript">
var _db = '<%=_db%>';

_jsonObj.classname = "com.wxtf.platform.main.sygl.noBirth_recordAction";
_jsonObj.methodname = "";
_jsonObj.logicdata = "[]";

var win;//修改弹出框

var manager;//人员表格

$(function(){
	manager = $("#emp-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height:'94%',
		usePager: true, rownumbers: true, checkbox: true,alternatingRow: true,onAfterShowData: function(data, currentPageData)
		 {
		 	//allProps(data);
		 	 $("#emp").val(data.emp);
		     $("#memp").val(data.memp);
		     $("#femp").val(data.femp);
		 },
		columns: [
			{ display: 'tbenhbcr_id', name: 'tbenhbcr_id', hide: true,width:1 },
			{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '机构名称', name: 'reserve1', width: 150, align: 'left'},
			{ display: '是否不孕症', name: 'tbe_is_barrenness', width:  1, hide:true },
			{ display: '是否绝经', name: 'the_is_menopause', width:  1, hide:true },
			{ display: '姓名', name: 'tbenhbcr_name', width: 100, align: 'left',isSort:false,render: function(record, index, value, oth){
					return " <a href='javascript:addData(" + JSON.stringify(record) + ")'>"+value+"</a>";
				}
			},
			{ display: '性别', name: 'tbenhbcr_sex', width: 60, align: 'left',isSort:false },
			{ display: '年龄', name: 'tbenhbcr_age', hide: true,width:1 },
			{ display: '员工身份证号', name: 'tbenhbcr_idcard', width: 150, align: 'left',isSort:false },
			{ display: 'tbenhbcr_spouse_name', name: 'tbenhbcr_spouse_name', hide: true,width:1 },
			{ display: 'tbenhbcr_spouse_sex', name: 'tbenhbcr_spouse_sex', hide: true,width:1 },
			{ display: 'tbenhbcr_spouse_age', name: 'tbenhbcr_spouse_age', hide: true,width:1 },
			{ display: 'tbenhbcr_spouse_idcard', name: 'tbenhbcr_spouse_idcard', hide: true,width:1 },
			{ display: '婚姻状态', name: 'tbenhbcr_marital_status', width: 100, align: 'left',isSort:false,
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%
						temp = map.get("tmgd_name");
						%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			},
			{ display: '婚姻状况', name: 'tbenhbcr_marital_condition',width: 1, hide:true},
			{ display: '无生育条件状态', name: 'tbenhbcr_reason', width:150,align:'left'},
			{ display: '备注', name: 'tbenhbcr_memo', width:  1, hide:true },
			{ display: 'reserve2', name: 'reserve2', width:  1, hide:true },
			{ display: 'reserve3', name: 'reserve3', width:  1, hide:true },
			{ display: 'reserve4', name: 'reserve4', width:  1, hide:true },
			{ display: 'reserve5', name: 'reserve5', width:  1, hide:true },
			{ display: '录入人', name: 'create_by', width:  1, hide:true },
			{ display: '录入时间', name: 'create_time', width:  1, hide:true },
			{ display: '最后修改人', name: 'last_modify_by', width:  1, hide:true },
			{ display: '最后修改时间', name: 'last_modify_time', width: 1, hide:true },
			{ display: '编辑', name:'edit', isSort:false,width:60,isSort:false,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/edit.gif' onclick='addData(" + JSON.stringify(record) + ")'></img>";
				}
			}
		],
		toolbar: {
			items: [
				{ text: '删除', click: function(){ delData(); },icon: 'delete'}
			]
		}
		
	});

	
	/*
	 * 日期框
	 */
	$("#tbe_birthday").ligerDateEditor({ format: "yyyy-MM-dd", width:182 });
	$("#tbe_work_area").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	$("#tbe_join_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	$("#tbe_married_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	$("#tbe_es_time").ligerDateEditor({ format: "yyyy-MM-dd", width:182});
	
});

/*
 * 表格刷新
 */
function reload(){
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = "[{\"types\":\"init\"}]";
	manager.loadData();
}

/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	serch1();
	if(data.result || data.result == 'true'){
		succMsgTip(data.resultrecord);
	}else{
		warningTip(data.resultrecord);
	}
	if(win && data.result){
		win.hide();
	}
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}

/*
 * 获取列表选中的人员ID
 */
function getUserIds(){
	var arrayUsers = manager.getSelecteds();
	if(arrayUsers.length == 0){
		return "";
	} else {
		var text = "";
		for(var i=0; i<arrayUsers.length; i++){
			text += arrayUsers[i].tbenhbcr_id + ",";
		}
		return text.substring(0, text.length - 1);
	}
}

/*
 * 新增/修改人员
 */
function addData(row){
	document.getElementById('emp-form').reset();
	
	if(row){
		loadForm("emp-form", row);
		$("input[name='tbenhbcr_sex']").attr("disabled", true);
		$("#tbenhbcr_marital_status").attr("disabled", true);
		$("#org_id").attr("disabled", true);
	} else {
		$("#tbenhbcr_id").val('');
	}
	
	if(win == null){
		win = initWindowByDiv('empAdd-div', '编辑信息', 600, 320 ,save, closeWin);
	}else{
		win.show();
	}
}

/*
 * 新建/修改人员信息
 */
function save(){
	$("#org_id").attr("disabled", false);
	$("input[name='tbenhbcr_sex']").attr("disabled", false);
	$("#tbenhbcr_marital_status").attr("disabled", false);
	var tbenhbcr_memo = $('#tbenhbcr_memo').val();
	if(!checkIsString(tbenhbcr_memo)){
		warningTip("备注：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbenhbcr_memo) > 512){
		warningTip("备注：不能超过512字符");
		return;
	}
	var text = document.getElementById('org_id');
	text = text.options[text.selectedIndex].text.replaceAll('-','');
		$('#reserve1').val(text);
		//未生育条件原因
		var tbenhbcr_marital_status = $('#tbenhbcr_marital_status').val();
		if('8A90F0D0176C4961B322BEB26703A322' == tbenhbcr_marital_status){//离异
		$('#tbenhbcr_reason').val('离异');
		}
		else if('8A90F0D0176C4961B322BEB26703A323' == tbenhbcr_marital_status){//丧偶
			$('#tbenhbcr_reason').val("丧偶");
		}
		else{$('#tbenhbcr_reason').val('');}
		_jsonObj.logicdata = getForm("emp-form");
		var tbe_id = $("#tbenhbcr_id").val();		
		if(tbe_id == ''){
			_jsonObj.methodname = "save";
			callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
		} else {
			_jsonObj.methodname = "update";
			callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
		}
}

/*
 * 删除人员
 */
function delData(){
	var userIds = getUserIds();
	if(userIds == ""){
		warningTip('请至少选择一个用户进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？（删除不可恢复）', function (opt) { 			
		if(opt){
			_jsonObj.methodname = "delete";
			_jsonObj.logicdata = "[{\"ids\":\"" + userIds + "\"}]";
			callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
		}
	});
}




/*
 * 重置-条件查询
 */
function serReset(){

	$('#ser2').val('0');
	$('#ser3').val('');
	$('#ser1').val('');
}

/*
 * 条件查询
 */
function serch1(){
	var orgIds = $('#org2').val();

	var tbe_work_permit = $('#ser3').val();
	var tbe_name = $('#ser1').val();
	var tbe_spell_code = $('#ser2').val();

	
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds 
			+ '\",\"tbe_work_permit\":\"' + tbe_work_permit + '\",\"tbe_name\":\"' + tbe_name
			+ '\",\"tbe_spell_code\":\"' + tbe_spell_code 
			+ '\",\"types\":\"serch1\"}]';
	manager.loadData();
}

/*
 * 条件导出查询
 */
function expData(){
	var orgIds = $('#org2').val();
	var tbe_work_permit = $('#ser3').val();
	var tbe_name = $('#ser1').val();
	var tbe_spell_code = $('#ser2').val();
        	
	_jsonObj.methodname = "expData";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds 
			+ '\",\"tbe_work_permit\":\"' + tbe_work_permit + '\",\"tbe_name\":\"' + tbe_name
			+ '\",\"tbe_spell_code\":\"' + tbe_spell_code +'\"}]';
	callserver(_jsonObj, function(data, textStatus){
		if(data.result){
			downloadFile(data.resultrecord);
		} else {
			warningTip(data.resultrecord);
		}
	}, function(data, textStatus){
	});
}

/*
 * 婚姻状况事件
 */
function changeEvent1(ele){
	//未生育条件原因事件
	var tbenhbcr_marital_status = $('#tbenhbcr_marital_status').val();
	if('8A90F0D0176C4961B322BEB26703A322' == tbenhbcr_marital_status){//离异
	$('#tbenhbcr_reason').val('离异');
	return;
	}
	else if('8A90F0D0176C4961B322BEB26703A323' == tbenhbcr_marital_status){//丧偶
		$('#tbenhbcr_reason').val("丧偶");
		return;
	}
	else
	{
		$('#tbenhbcr_reason').val('');
		return;
	}
}

</script>
	</head>
	<body>
		<table class="serTable">
			<tr>
				<td>
					机构：
					<select id="org2" style="width: 163px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>

				<td>
					员工身份证号：
					<input id="ser3" style="width: 160px;" />
				</td>
				<td>
					<input class="btn2" value="搜索" type="button" onclick="serch1();" />
				</td>
				<td></td>
			</tr>
			<tr>
				<td>
					姓名：
					<input id="ser1" style="width: 160px;" />
				</td>
				<td>
					无生育状态：
					<select id="ser2" style="width: 163px;" />
						<option value="0">
							全部
						</option>
						<option value="不孕症">
							不孕症
						</option>
						<option value="绝经">
							绝经
						</option>
						<option value="离异">
							离异
						</option>
						<option value="丧偶">
							丧偶
						</option>
					</select>
				</td>
				<td>
					<input class="btn2" value="导出" type="button" onclick="expData();" />
				</td>
			</tr>
		</table>

		<div id="emp-grid"></div>
		<div style="font-size: 15px; text-align: left; margin-top: 5px;">
			注:已婚育龄无生育男
			<input type="text" id="memp"
				style="border: 0; width: 60px; border-bottom: 1px solid #000; text-align: center;" />
			人, 女
			<input type="text" id="femp"
				style="border: 0; width: 60px; border-bottom: 1px solid #000; text-align: center;" />
			人, 合计
			<input type="text" id="emp"
				style="border: 0; width: 60px; border-bottom: 1px solid #000; text-align: center;" />
			人。
		</div>
		<div id="empAdd-div" style="display: none;">
			<form id="emp-form" name="emp-form">
				<input type="hidden" id="tbenhbcr_id" name="tbenhbcr_id" value="" />
				<input type="hidden" id="tbe_id" name="tbe_id" value="" />
				<input type="hidden" id="tbenhbcr_spouse_name"
					name="tbenhbcr_spouse_name" value="0" />
				<input type="hidden" id="tbenhbcr_spouse_sex"
					name="tbenhbcr_spouse_sex" value="0" />
				<input type="hidden" id="tbenhbcr_spouse_age"
					name="tbenhbcr_spouse_age" value="0" />
				<input type="hidden" id="tbenhbcr_spouse_idcard"
					name="tbenhbcr_spouse_idcard" value="0" />
				<input type="hidden" id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="reserve2" name="reserve2" value="" />
				<input type="hidden" id="reserve3" name="reserve3" value="" />
				<input type="hidden" id="reserve4" name="reserve4" value="" />
				<input type="hidden" id="reserve5" name="reserve5" value="" />
				<input type="hidden" id="create_by" name="create_by" value="" />
				<input type="hidden" id="create_time" name="create_time" value="" />
				<input type="hidden" id="last_modify_by" name="last_modify_by"
					value="" />
				<input type="hidden" id="last_modify_time" name="last_modify_time"
					value="" />

				<table class="form_table">
					<tr>
						<td colspan="9" align="left">
							<div
								style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>基础信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">
							机构：
						</td>
						<td>
							<select id="org_id" name="org_id" style="width: 182px;">
								<%=user.getCurSubOrgOptions()%>
							</select>
						</td>
						<td></td>
						<td class="form_label">
							姓名：
						</td>
						<td>
							<input class="textbg1" id="tbenhbcr_name" name="tbenhbcr_name"
								readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">
							身份证号：
						</td>
						<td>
							<input class="textbg1" id="tbenhbcr_idcard"
								name="tbenhbcr_idcard" readonly="readonly"
								onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">
							性别：
						</td>
						<td align="left" id="tbenhbcr_sex">
							<input style="margin-top: 2px;" type="radio" id="tbenhbcr_sex"
								name="tbenhbcr_sex" value="男" />
							男
							<input style="margin-top: 2px;" type="radio" id="tbenhbcr_sex"
								name="tbenhbcr_sex" value="女" checked="checked" />
							女
						</td>
						<td></td>
					</tr>
					<tr>
						<td colspan="9" align="left">
							<div
								style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>婚姻信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">
							婚姻状态：
						</td>
						<td>
							<select id="tbenhbcr_marital_status"
								name="tbenhbcr_marital_status" readonly="readonly"
								onchange="changeEvent1(this);"
								style="width: 182px; margin-left: 1px;">
								<%=tbe_marital_status%>
							</select>
						</td>
						<td style="display: none;">
							婚姻状况：
						</td>
						<td style="display: none;">
							<select id="tbenhbcr_marital_condition"
								name="tbenhbcr_marital_condition" onchange="changeEvent1(this);"
								style="width: 182px; margin-left: 1px;">
								<option value=""></option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td colspan="9" align="left">
							<div
								style="border-bottom: 1px solid #EBEBEB; font-weight: bold; height: 28px; line-height: 28px; margin: 0 0 5px;">
								<img src="ligerUI/skins/icons/communication.gif" />
								<span>生育信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">
							是否不孕症：
						</td>
						<td align="left" id="tbe_is_barrenness">
							<input style="margin-top: 2px; margin-left: 5px;" type="radio"
								name="tbe_is_barrenness" value="1" />
							是
							<input style="margin-top: 2px; margin-left: 5px;" type="radio"
								name="tbe_is_barrenness" value="0" checked="checked" />
							否
						</td>
						<td></td>
						<td class="form_label">
							是否绝经：
						</td>
						<td align="left" id="the_is_menopause">
							<input style="margin-top: 2px; margin-left: 5px;" type="radio"
								name="the_is_menopause" value="1" />
							是
							<input style="margin-top: 2px; margin-left: 5px;" type="radio"
								name="the_is_menopause" value="0" checked="checked" />
							否
						</td>
						<td></td>
					</tr>
					<tr style="display: none;">
						<td class="form_label">
							无生育条件原因：
						</td>
						<td>
							<input class="textbg1" id="tbenhbcr_reason"
								name="tbenhbcr_reason" onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
						<td class="form_label">
							年龄：
						</td>
						<td>
							<input class="textbg1" id="tbenhbcr_age" name="tbenhbcr_age"
								onMouseOver="this.style.borderColor='#4fa8e6'"
								onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">
							备注：
						</td>
						<td>
							<input class="textbg1" id="tbenhbcr_memo" name="tbenhbcr_memo" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td>
							<br />
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>